
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>第1节: http_access_module · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="http_auth_basic_module.html" />
    
    
    <link rel="prev" href="./" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../Chapter1/">
            
                <a href="../Chapter1/">
            
                    
                    第一章
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../Chapter1/nginx安装.html">
            
                <a href="../Chapter1/nginx安装.html">
            
                    
                    第1节：nginx安装
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="./">
            
                <a href="./">
            
                    
                    第二章 nginx模块
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.3.1" data-path="http_access_module.html">
            
                <a href="http_access_module.html">
            
                    
                    第1节: http_access_module
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="http_auth_basic_module.html">
            
                <a href="http_auth_basic_module.html">
            
                    
                    第2节: http_auth_basic_module
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >第1节: http_access_module</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x7B2C;1&#x8282;-httpaccessmodule">&#x7B2C;1&#x8282;: http_access_module</h1>
<p>Syntax:  <code>allow address | CIDR | unix: |all;</code></p>
<p>Default  <code>-</code></p>
<p>Context: <code>http,server,location,limit_except</code></p>
<p>Syntax: <code>deny address | CIDR |unix: | all;</code></p>
<p>Default: <code>-</code></p>
<p>Context:<code>http,server,location,limit_except</code></p>
<p>&#x914D;&#x7F6E;nginx.conf</p>
<p>&#x65B0;&#x589E;&#x5982;&#x4E0B;location</p>
<pre><code class="lang-nginx"><span class="hljs-attribute">location</span> <span class="hljs-regexp">~ ^/admin.html</span>{

    <span class="hljs-attribute">root</span> /www/html;

    <span class="hljs-attribute">deny</span> <span class="hljs-number">192.168.127.3</span>     <span class="hljs-comment">#&#x4E0D;&#x5141;&#x8BB8;&#x81EA;&#x5DF1;&#x7684;ip&#x8BBF;&#x95EE;</span>

    allow all;            <span class="hljs-comment">#&#x5141;&#x8BB8;&#x5176;&#x4ED6;&#x6240;&#x6709;ip&#x8BBF;&#x95EE;</span>

    <span class="hljs-attribute">index</span> index.html index.htm;

}
</code></pre>
<p>&#x53EA;&#x5141;&#x8BB8;&#x81EA;&#x5DF1;&#x7684;IP&#x8BBF;&#x95EE;</p>
<pre><code class="lang-nginx"><span class="hljs-attribute">location</span> <span class="hljs-regexp">~ ^/admin.html</span>{

    <span class="hljs-attribute">root</span> /www/html;

    <span class="hljs-attribute">deny</span>  all    <span class="hljs-comment">#&#x4E0D;&#x5141;&#x8BB8;&#x5176;&#x4ED6;&#x6240;&#x6709;ip&#x8BBF;&#x95EE;</span>

    allow <span class="hljs-number">192.168.127.3</span>;<span class="hljs-comment">#&#x5141;&#x8BB8;&#x81EA;&#x5DF1;&#x7684;ip&#x8BBF;&#x95EE;</span>

    <span class="hljs-attribute">index</span> index.html index.htm;

}
</code></pre>
<p>http_x_forwarded_for</p>
<p><img src="http_x_forwarded_for.png" alt="http_x_forwarded_for"></p>
<p><code>http_x_forwarded_for=Client IP,Proxy(1)IP,Proxy(2)IP</code></p>
<p>http_access_module&#x5C40;&#x9650;&#x6027;</p>
<ul>
<li>&#x91C7;&#x7528;&#x522B;&#x7684;HTTP&#x5934;&#x4FE1;&#x606F;&#x63A7;&#x5236;&#x8BBF;&#x95EE; &#x5982;:HTTP_X_FORWARE_FOR</li>
<li>&#x7ED3;&#x5408;geo&#x6A21;&#x5757;</li>
<li>&#x901A;&#x8FC7;HTTP&#x81EA;&#x5B9A;&#x4E49;&#x53D8;&#x91CF;&#x4F20;&#x9012;</li>
</ul>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="./" class="navigation navigation-prev " aria-label="Previous page: 第二章 nginx模块">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="http_auth_basic_module.html" class="navigation navigation-next " aria-label="Next page: 第2节: http_auth_basic_module">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"第1节: http_access_module","level":"1.3.1","depth":2,"next":{"title":"第2节: http_auth_basic_module","level":"1.3.2","depth":2,"path":"Chapter2/http_auth_basic_module.md","ref":"Chapter2/http_auth_basic_module.md","articles":[]},"previous":{"title":"第二章 nginx模块","level":"1.3","depth":1,"path":"Chapter2/README.md","ref":"Chapter2/README.md","articles":[{"title":"第1节: http_access_module","level":"1.3.1","depth":2,"path":"Chapter2/http_access_module.md","ref":"Chapter2/http_access_module.md","articles":[]},{"title":"第2节: http_auth_basic_module","level":"1.3.2","depth":2,"path":"Chapter2/http_auth_basic_module.md","ref":"Chapter2/http_auth_basic_module.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"Chapter2/http_access_module.md","mtime":"2018-12-27T14:34:50.526Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-12-27T14:48:52.325Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

